<template>
  <div class="login-container">
     <!-- 登录标题 -->
     <div class="login-title">
       <span class="login-title-text">质量检验信息服务平台</span>
     </div>


   <!-- 登录表单容器 -->
     <div 
       class="login-from-container" 
       :class="{ 
         'is-mobile': isMobile,
         'is-tablet': isTablet,
         'is-portrait': isPortrait 
       }"
     >
      <div class="login-from-title">{{ getLoginTitle }}</div>
        <div class="login-from-content">
          <PCLoginForm v-if="!isMobile && !isTablet" />
          <MobileLoginForm v-else />
        </div>
     </div>
  </div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { useDesign } from '@/hooks/web/useDesign'
import { PCLoginForm, MobileLoginForm } from './components'
import { useDeviceDetect } from '@/hooks/web/useDeviceDetect'

defineOptions({ name: 'Login' })

const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('login')

// 使用设备检测 hook，设置移动端断点为 768px
const { isMobile, isTablet, isPortrait, deviceInfo } = useDeviceDetect(768)

// 根据设备类型显示不同的标题
const getLoginTitle = computed(() => {
  if (deviceInfo.value.userAgent.includes('micromessenger')) {
    return '微信登录'
  }
  if (deviceInfo.value.userAgent.includes('alipay')) {
    return '支付宝登录'
  }
  return '用户登录'
})
</script>

<style lang="scss" scoped>
$prefix-cls: #{$namespace}-login;

.#{$prefix-cls} {
  overflow: auto;

  &__left {
    &::before {
      position: absolute;
      top: 0;
      left: 0;
      z-index: -1;
      width: 100%;
      height: 100%;
      background-image: url('@/assets/svgs/login-bg.svg');
      background-position: center;
      background-repeat: no-repeat;
      content: '';
    }
  }
}
</style>

<style lang="scss">



.dark .login-form {
  .el-divider__text {
    background-color: var(--login-bg-color);
  }

  .el-card {
    background-color: var(--login-bg-color);
  }
}
</style>


<style lang="scss" scoped>
.login-container {
  width: 100%;
  height: 100%;
  padding: 30px;
  background-image: url('@/assets/imgs/login/image.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  
  &::before {
    position: absolute;
    top: 26%;
    left: 5%;
    width: 100%;
    height: 100%;
    background: url('@/assets/imgs/login/login-bg.webp') no-repeat;
    background-size: 52% 60%;
    content: '';
    
    // 移动端样式
    @media screen and (width <= 768px) {
      top: 10%;
      left: 0;
      background-size: 100% 30%;
    }
  }

  .login-title {
    width: 100%;

    .login-title-text {
      margin-left: 30px;
      font-size: 24px;
      font-weight: 600;
      letter-spacing: 5px;
      color: #000;
      
      @media screen and (width <= 768px) {
        margin-left: 0;
        font-size: 20px;
        letter-spacing: 3px;
        text-align: center;
      }
    }
  }

  .login-from-container {
    position: absolute;
    inset: 282px 184px 282px 1093px;
    width: 600px;
    height: 500px;
    padding: 50px;
    background-image: url('@/assets/imgs/login/runPic_114.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    transition: all 0.3s ease;

    &.is-mobile,
    &.is-tablet {
      position: relative;
      top: 45%;
      left: 50%;
      width: 90%;
      height: auto;
      min-height: 400px;
      padding: 30px;
      background-image: url('@/assets/imgs/login/runPic_114.png');
      border-radius: 15px;
      transform: translateX(-50%);
      box-shadow: 0 0 20px rgb(0 0 0 / 10%);

      &.is-portrait {
        margin-top: 20px;
      }
    }

    // 平板特有样式
    &.is-tablet {
      width: 80%;
      max-width: 800px;
      min-height: 500px;
      padding: 40px;
    }

    .login-from-title {
      position: absolute;
      top: 3%;
      left: 50%;
      font-size: 24px;
      font-weight: 600;
      color: rgb(202 219 255 / 100%);
      text-align: center;
      transform: translateX(-50%);
      
      @media screen and (width <= 768px) {
        font-size: 20px;
      }
    }

    .login-from-content {
      margin-top: 100px;
      
      @media screen and (width <= 768px) {
        margin-top: 80px;
      }
    }
  }
}
</style>
